<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2006/05/18 22:20:30 $)
// $RCSfile: impex.emailqueues.php,v $ : $Revision: 1.1 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

/**
* Return the Total Pages for this Plugin
*/
function getPluginTotalPages6()
{
	return 1;
}

/**
* Run the specific page for plugin
*/
function runPluginPage6($page)
{
	global $impexDB, $_IMPEXHASH;

	$queuelist = array();
	$impexDB->query("SELECT * FROM `gateway` ORDER BY `id` ASC;");
	while ($impexDB->nextRecord())
	{
		_impexProcessSlashVariables($impexDB->Record);

		$queuelist[$impexDB->Record["id"]] = $impexDB->Record;
	}

	foreach ($queuelist as $key=>$val)
	{
		$newdepartmentid = intval($_IMPEXHASH["departmentpointer"][$val["category"]]);
		if (empty($newdepartmentid))
		{
			displayStatus("<font color='red'>WARNING:</font> Import of Email Queue Failed due to Non Existant Department: ".htmlspecialchars($val["email"]));
		} else {
			$_emailqueueid = _impexInsertEmailQueue($val["email"], $newdepartmentid, "pipe", "", "", "", "", "");

			$_IMPEXHASH["queuepointer"][$key] = $_emailqueueid;

			displayStatus("Imported Email Queue: ".htmlspecialchars($val["email"]));
		}
	}

	return true;
}
?>